<?php

namespace app\common\middleware;

use app\common\NSWhiteIp;
use think\facade\Config;

class BlockIp
{
    public function handle($request, \Closure $next)
    {
        if (Config::get('white.switch') && !($can = NSWhiteIp::check_ip())) {
            header("HTTP/1.1 403 Forbidden");
            echo "403 Forbidden Your Ip is :" . get_client_ip();
            exit();
        }
        return $next($request);
    }
}
